#ifndef CROWDSIMFRAMELISTENER_H
#define CROWDSIMFRAMELISTENER_H

#include "OGRE/ExampleApplication.h"
#include "OgreBulletDynamicsRigidBody.h"				 // for OgreBullet
#include "Shapes/OgreBulletCollisionsStaticPlaneShape.h" // for static planes
#include "Shapes/OgreBulletCollisionsBoxShape.h"		 // for Boxes

#include <vector>
#include <string>

struct RoadmapVertex {
	Vector3 position;
	std::vector<int> neighbors;
	std::vector<float> distToGoal;
};

class CrowdSimFrameListener : public ExampleFrameListener
{
private:
	SceneManager* mSceneMgr; 
	OgreBulletDynamics::DynamicsWorld *mWorld;	// OgreBullet World
	OgreBulletCollisions::DebugDrawer *debugDrawer;
	int mNumEntitiesInstanced;
	std::vector<RoadmapVertex> roadmap;
	std::deque<OgreBulletDynamics::RigidBody *>         mBodies;
	std::deque<OgreBulletCollisions::CollisionShape *>  mShapes;

	OgreBulletDynamics::RigidBody *defaultBody;

public:
	CrowdSimFrameListener(
		SceneManager *sceneMgr, 
		RenderWindow* win, 
		Camera* cam,
		Vector3 &gravityVector,
		AxisAlignedBox &bounds);
	~CrowdSimFrameListener();
	bool frameStarted(const FrameEvent& evt);
	bool frameEnded(const FrameEvent& evt);
	virtual bool processUnbufferedKeyInput(const FrameEvent& evt);
	void readRoadMap();
	void buildRoadMap();
	bool queryVisibility(Vector3, Vector3);
};
#endif